﻿using System;
using System.Collections.Generic;
using System.Text;
using HZU.ZP.Data.Interfaces;
using HZU.ZP.Domain.IService;
using HZU.ZP.Domain.Model;
using HZU.ZP.Domain.ServiceImpl.Mappers;

namespace HZU.ZP.Domain.ServiceImpl.PCSvc
{
    public class ApplicantService : IApplicantService
    {
        private ApplicantMapper _mapper = new ApplicantMapper();
        private ApplicantInfMapper _mapperInf = new ApplicantInfMapper();
        private IApplicantDao _sqlData;
        public ApplicantService(IApplicantDao sqlData)
        {
            _sqlData = sqlData;
        }
        public Applicant Login(string email, string password)
        {
            var applicant = _sqlData.Get(email, password);
            return _mapper.MapToDomain(applicant);
        }

        public bool Register(Applicant applicant)
        {
            var applicantDao = _mapper.MapToDao(applicant);
            _sqlData.Add(applicantDao);
            return true;
        }
        public IList<ApplicantInf> GetAppInf(int pageIndex)
        {
            return _mapperInf.MapToDomainList(_sqlData.Get(pageIndex));
        }
        public int GetAppInfCount()
        {
            return _sqlData.GetCount();
        }

        public Applicant GetApplicant(string email)
        {
            return _mapper.MapToDomain(_sqlData.Get(email));
        }
    }
}
